/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uq.comp7705.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author javierpanchi
 */
@Entity
@Table(name = "drk_session_drink")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SessionDrink.findAll", query = "SELECT s FROM SessionDrink s"),
    @NamedQuery(name = "SessionDrink.findById", query = "SELECT s FROM SessionDrink s WHERE s.id = :id"),
    @NamedQuery(name = "SessionDrink.findByQuantity", query = "SELECT s FROM SessionDrink s WHERE s.quantity = :quantity"),
    @NamedQuery(name = "SessionDrink.findBySession", query = "SELECT s FROM SessionDrink s WHERE s.drkSessionId.id= :session and s.drkSessionId.closed=0 order by s.id desc"),
    @NamedQuery(name = "SessionDrink.findByDrinkIdSessionId", query = "SELECT s FROM SessionDrink s WHERE s.drkDrinksId.id= :idDrink and s.drkSessionId.id= :idSession and s.drkSessionId.closed=0 order by s.id desc"),
    @NamedQuery(name = "SessionDrink.findByDrinkSession", query = "SELECT s FROM SessionDrink s WHERE s.drkDrinksId.id = :drink and s.drkSessionId.id= :session and s.drkSessionId.closed=0 order by s.id desc")})
public class SessionDrink implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "quantity")
    private int quantity;
    @JoinColumn(name = "drk_session_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Session drkSessionId;
    @JoinColumn(name = "drk_drinks_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Drink drkDrinksId;
 
    public SessionDrink() {
    }

    public SessionDrink(Integer id) {
        this.id = id;
    }

    public SessionDrink(Integer id, int quantity) {
        this.id = id;
        this.quantity = quantity;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Session getDrkSessionId() {
        return drkSessionId;
    }

    public void setDrkSessionId(Session drkSessionId) {
        this.drkSessionId = drkSessionId;
    }

    public Drink getDrkDrinksId() {
        return drkDrinksId;
    }

    public void setDrkDrinksId(Drink drkDrinksId) {
        this.drkDrinksId = drkDrinksId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SessionDrink)) {
            return false;
        }
        SessionDrink other = (SessionDrink) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.uq.comp7705.entity.SessionDrink[ id=" + id + " ]";
    }
    
}
